/*
 <!--计划管理----价格管理-->
 * 
 * 2017-11-18
 * 
 * 
 * */
$(function(){	
		$.ajax({
			type:"post",
			url:"https://jindi163.com:8443/JDLot/lottype/alllist",
			async:true,
			data:{},
			dataType:'json', 
			contentType:"application/json",
			success:function(res){
				var res=res.datas;
			var html="";
			for (var i=0;i<res.length;i++) {
				var list= res[i].lottery_name;
				html+='<span class="ishide_all" style="opacity:0">'+list+'</span><option>'+res[i].lottery_full_name+'</option>'
			}
			$("#all_cai").append(html);
		var phone=sessionStorage.getItem("phone");
			$("#gaijiage").click(function(){
					var aas=$('#all_cai option:selected').prev().text();
					var days=$("#days").val();
					var months=$("#months").val();
					var wenkend=$("#wenkend").val();
					var planId=$("#idsg").text();
				   console.log(planId+"===="+aas+"===="+months+"===="+wenkend+"===="+days)
		 $.ajax({
				  type: "post",
				  url: "https://jindi163.com:8443/JDLot/price/plan/upload",
				 	dataType: "json",
				  contentType:"application/json",
				  xhrFields: {
   						 withCredentials: true
						},
					crossDomain: true,
				   data: {
						planId:planId,
						priceDay:days,
						lotteryname:aas,
						priceWeek:wenkend,
						priceMonth:months,
						status:"2"
						
				  },
				  async:true,
				  success: function(datas){
				  	console.log(datas);
				      if(datas.msgContext=="success") {
				      alert("修改成功!")
				      }
				      else{ 
				      	alert("修改失败1")
				      }
				      
				  }
				});
				   
		})
			

			$('#all_cai').change(function(){
				shows()
			})
			
			
			
			
	function shows(){
var phone=sessionStorage.getItem("phone");
var aas=$('#all_cai option:selected').prev().text();
//alert(aas)
			  $.ajax({
				  type:"post",
				  url: "https://jindi163.com:8443/JDLot/price/plan/query/lotteryname",
				  data: {
				  	phone:phone,
				  	lotteryname:aas//彩种名称
				  },
				  dataType: "json",
                  contentType:"application/json",
                  async:true,
                  cache:false,
                  xhrFields: {
   						 withCredentials: true
						},
					crossDomain: true,
				  success: function(datas){
			console.log(datas)
			var res = datas.datas;
//			console.log(res)
				     var html="";
				     $("#one_cai").empty();
			for (var i=0;i<res.length;i++) {
				var list= res[i].plan_id;
				html+='<span class="ishide_all" style="opacity:0">'+list+'</span><option>'+res[i].plan_name+'</option>'
			}
			$("#one_cai").append(html);
				  },
				}); 
				
			}
	
	
	
			$("#gaijiage1").click(function(){
					var aas=$('#all_cai option:selected').prev().text();
					var aas1=$('#one_cai option:selected').prev().text();
					var days1=$("#days1").val();
					var months1=$("#months1").val();
					var wenkend1=$("#wenkend1").val();
					console.log(aas+";;;;;"+aas1+";;;;;"+days1 +";;;;;"+ months1+";;;;;"+ wenkend1)
				   
		$.ajax({
				  type: "post",
				  url: "https://jindi163.com:8443/JDLot/price/plan/upload",
				  data: {
				  		planId:aas1,
						priceDay:days1,
						lotteryname:aas,
						priceWeek:wenkend1,
						priceMonth:months1,
						status:"3"
				  },
				  xhrFields: {
   						 withCredentials: true
						},
					crossDomain: true,
				  dataType: "json",
				  async:true,
				  contentType:"application/json",
				  success: function(datas){
				  	console.log(datas)
				      if(datas.msgContext=="success") {
				      alert("修改成功!")
				      }
				      else{ 
				      	alert("修改失败1")
				      }
				      
				  }
				});
				   
			})

			
			
			
			
			
			
			}
		});

})
